<?php

class ReportsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }

    public function getcandidatesAction()
    {
        
        $start = $this->getRequest()->getParam('start');
        $limit = $this->getRequest()->getParam('limit');
        $isRefer = $this->getRequest()->getParam('isrefer') == 'true';
        
        $model = new Model_Reservacandidatos();        
        
        $data = $model->getCandidates($isRefer, $start, $limit);
        
        if(is_array($data['data'])){
            $msg = 1;
            $success = true;
        }else{
            $msg = 'Error al consultar los datos';
            $success = false;
            $data = array();
        }
        $response = array(
            'success' => $success,
            'msg' => $msg,
            'data' => $data['data'],
            'total' => $data['total']
        );
        $this->_helper->json->sendJson($response);
    }

    public function getrequestAction()
    {
        $start = $this->getRequest()->getParam('start');
        $limit = $this->getRequest()->getParam('limit');
        
        $model = new Model_Informacionsolicitud();        
        
        $data = $model->getRequest($start, $limit);
        
        if(is_array($data['data'])){
            $msg = 1;
            $success = true;
        }else{
            $msg = 'Error al consultar los datos';
            $success = false;
            $data = array();
        }
        $response = array(
            'success' => $success,
            'msg' => $msg,
            'data' => $data['data'],
            'total' => $data['total']
        );
        $this->_helper->json->sendJson($response);
    }

    public function getrequeststatusreportAction()
    {
        $start = $this->getRequest()->getParam('start');
        $limit = $this->getRequest()->getParam('limit');
        
        $dbeg = $this->getRequest()->getParam('dbeg');
        $dend = $this->getRequest()->getParam('dend');
        
        $dbeg = ($dbeg)?$dbeg:-1;
        $dend = ($dend)?$dend:-1;
        
        $model = new Model_Reports();
        $data = $model->getRequestsReport($dbeg, $dend, $start, $limit);
        
        if(is_array($data['data'])){
            $msg = 1;
            $total = $data['total'];
            $success = true;
            $report = $data['data'];
        }else{
            $total = 0;
            $success = false;
            $report = array();
            $msg = 'Error al consultar los datos del reporte';
        }
        
        $response = array(
            'success' => $success,
            'data' => $report,
            'msg' => $msg,
            'total' => $total
        );
        $this->_helper->json->sendJson($response);
        
    }

}











